/**
 * 
 */
package com.vision.core.cm.serv.rpc;

import java.util.List;

import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.vision.core.cm.db.data.Company;
import com.vision.core.cm.db.data.Role;
import com.vision.core.cm.db.data.User;
import com.vision.core.cm.exception.RpcException;

/**
 * @author Mark
 *
 */
@RemoteServiceRelativePath("users")
public interface UserService extends AbstractService<User> {
	
	/**
	 * Returns the information about the currently logged in {@link User}.
	 * 
	 * @return
	 * @throws RpcException
	 */
	User getProfile() throws RpcException;
	
	/**
	 * Returns the {@link User} with the given <tt>username</tt>.
	 * 
	 * @param username
	 * @return
	 * @throws RpcException
	 */
	User getByUsername(String username) throws RpcException;
	
	/**
	 * Updates the {@link User}'s own profile information.
	 * 
	 * @param user - {@link User} instance containing the new information
	 * @param oldPassword - the {@link User}'s old password, used for verification if <tt>user</tt> contains a new password
	 * 
	 * @return
	 * @throws RpcException
	 */
	User updateOwnProfile(User user, String oldPassword) throws RpcException;
	
	/**
	 * Assigns <tt>companies</tt> to the specified <tt>user</tt>. 
	 * 
	 * @param user
	 * @param companies
	 * @return
	 * @throws RpcException
	 */
	List<Company> assignCompanies(User user, List<Company> companies) throws RpcException;
	
	/**
	 * Unassigns <tt>companies</tt> to the specified <tt>user</tt>.
	 * 
	 * @param user
	 * @param companies
	 * @return
	 * @throws RpcException
	 */
	List<Company> unassignCompanies(User user, List<Company> companies) throws RpcException;
	
	/**
	 * Assigns the specified {@link Role}s to the <tt>user</tt>.
	 * 
	 * @param user
	 * @param roles
	 * @return
	 * @throws RpcException
	 */
	List<Role> assignRoles(User user, List<Role> roles) throws RpcException;
	
	/**
	 * Unassigns the specified {@link Role}s from the <tt>user</tt>.
	 * 
	 * @param user
	 * @param roles
	 * @return
	 * @throws RpcException
	 */
	List<Role> unassignRoles(User user, List<Role> roles) throws RpcException;
	
	/**
	 * Activates the user account.
	 * @param user
	 * @return
	 * @throws RpcException
	 */
	User activate(User user) throws RpcException;
	
	/**
	 * Deactivates the user account.
	 */
	User deactivate(User user) throws RpcException;
	
}
